//
//  RootViewController.m
//  UI7_UINavigationController
//
//  Created by TravelRound on 15/11/17.
//  Copyright © 2015年 TravelRound. All rights reserved.
//

#import "RootViewController.h"
#import "SecondViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    
    self.navigationController.navigationBar.barTintColor = [UIColor yellowColor];
    
    self.navigationItem.title = @"aaa";
    
    
    // navigationItem管理着左/右/标题视图
    self.navigationItem.title = @"第一页";
    
//    UISegmentedControl *segC = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"王宁", @"汤姆猫", nil]];
//    self.navigationItem.titleView = segC;
//    [segC release];
    
    // 设置右视图
    // 参数1 - 显示的标题
    // 参数2 - 样式(IOS7以后基本相同)
    // 参数3&参数4 - 参照BUTTON注册的处理方法
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"下一页" style:UIBarButtonItemStylePlain target:self action:@selector(rightAction:)] autorelease];
    
}

- (void)rightAction:(UIBarButtonItem *)sender
{
    
    SecondViewController *secondVC = [[SecondViewController alloc] init];
    
    // 不在本身切换逻辑内的用模态(presentViewController)方式
    [self.navigationController pushViewController:secondVC animated:YES];
    
    [secondVC release];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
